﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Mokkula
{
    public partial class SignalIndicatorControl : UserControl
    {
        private double _signal;

        /// <summary>
        /// Get or set the signal value (0-100).
        /// </summary>
        public double Signal
        {
            get { return _signal*100; }
            set { _signal = value / 100; this.Invalidate(); }
        }

        public SignalIndicatorControl()
        {
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            DrawBar(e.Graphics);
            base.OnPaint(e);
        }

        private void DrawBar(Graphics graphics)
        {
            int width = (int)(this.Bounds.Width * _signal);
            Rectangle bounds = new Rectangle(Point.Empty, new Size(width, this.Height));
            graphics.FillRectangle(Brushes.DarkGreen, bounds);
        }
    }
}
